﻿using AutoMapper;
using Domain;
using RabbitTraceability.Api.Applications.Command;
using RabbitTraceability.Api.Dtos.Request;
using RabbitTraceability.Api.Dtos.Response;

namespace RabbitTraceability.Api
{
    public class MapperProFile : Profile
    {
        public MapperProFile()
        {
            CreateMap<AddTraceabilityInfoCommand, TraceabilityInfo>()
                .ForMember(dest => dest.TraceabilityId, opt => opt.Ignore())
                .ReverseMap();
                
            // 添加溯源信息到DTO的映射
            CreateMap<TraceabilityInfo, TraceabilityInfoDto>();
            
            // 添加图片信息到DTO的映射
            CreateMap<ImageInfo, ImageInfoDto>();
            
            // 养殖信息映射
            CreateMap<SaveBreedingInfoRequestDto, SaveBreedingInfoCommand>();
            CreateMap<BreedingInfo, BreedingInfoResponseDto>();
            
            // 保健信息映射
            CreateMap<AddHealthCareInfoCommand, HealthCareInfo>()
                .ForMember(dest => dest.HealthCareId, opt => opt.Ignore())
                .ReverseMap();
            CreateMap<HealthCareInfo, HealthCareInfoResponseDto>();
        }
    }
}
